package net.dgg.rz.common.utils;

import net.dgg.framework.tac.utils.bean.DggRestResponse;

import java.util.List;
import java.util.Map;

/**
 * dataTable 表格返回数据结构体
 * @Author:HDC
 * @Date: Created in 2018/5/8 16:13
 */
public class DataTableResponse extends DggRestResponse {
    private Object recordsTotal;// 总记录数
    private Object recordsFiltered; // 当前记录数
    private Object pageSize; // 当前记录数
    private Object size; // 当前记录数
    private Object draw;// datatable必要参数
    private Object resultData;// datatable必要参数

    public DataTableResponse data(Map params, List<?> data,Object resultData) {
        this.resultData =  resultData;
        this.recordsTotal = params.get("count");
        this.recordsFiltered = params.get("count");
        this.draw = params.get("draw");
        this.pageSize = params.get("pageSize");
        this.size = params.get("size");
        this.setData(data);
        return this;
    }

    public DataTableResponse data(Map params, List<?> data) {
        this.recordsTotal = params.get("count");
        this.recordsFiltered = params.get("count");
        this.draw = params.get("draw");
        this.pageSize = params.get("pageSize");
        this.size = params.get("size");
        this.setData(data);
        return this;
    }

    public DataTableResponse data(List<?> data) {
        this.recordsTotal = 0;
        this.setData(data);
        return this;
    }

    public Object getRecordsTotal() {
        return recordsTotal;
    }

    public void setRecordsTotal(Object recordsTotal) {
        this.recordsTotal = recordsTotal;
    }

    public Object getRecordsFiltered() {
        return recordsFiltered;
    }

    public void setRecordsFiltered(Object recordsFiltered) {
        this.recordsFiltered = recordsFiltered;
    }

    public Object getDraw() {
        return draw;
    }

    public void setDraw(Object draw) {
        this.draw = draw;
    }

    public Object getPageSize() {
        return pageSize;
    }

    public void setPageSize(Object pageSize) {
        this.pageSize = pageSize;
    }

    public Object getSize() {
        return size;
    }

    public void setSize(Object size) {
        this.size = size;
    }

    public Object getResultData() {
        return resultData;
    }

    public void setResultData(Object resultData) {
        this.resultData = resultData;
    }
}
